<include file="Public/header"/>
<div class="row">
    <div class="col-md-12">
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h5>修改个人手机</h5>
            </div>
            <div class="ibox-content">
                <!--用户信息-->
                <form class="layui-form" action="" autocomplete="off" id="editmobile">
                    
   
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <if condition="$editmobile">
                                <label class="layui-form-label">新手机：</label>
                                <div class="layui-input-inline">
                                <input type="text" name="mobile"  lay-verify="phone" autocomplete="off"
                                       class="layui-input" id="mobile" value="" >
                                </div>
                            <else/>
                                <label class="layui-form-label">绑定手机：</label>
                                <div class="layui-input-inline">
                                <input type="text"  disabled lay-verify="phone" autocomplete="off"
                                       class="layui-input" value="<{$mobile}>" >
                                </div>
                            </if>
                        </div>
                    </div>

                    <include file="Public/send"/>
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn" lay-submit="" lay-filter="editmobile">立即提交</button>
                            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                        </div>
                    </div>
                </form>
                <!--用户信息-->
            </div>
        </div>
    </div>
</div>
<include file="Public/footer"/>
<script>
    //短信验证是否开启
    var sms_is_open = "<{$sms_is_open}>";
    layui.use(['laydate', 'laypage', 'layer', 'form', 'element'], function() {
        var laydate = layui.laydate //日期
            ,layer = layui.layer //弹层
            ,form = layui.form //弹层
            , element = layui.element; //元素操作
        //日期
        laydate.render({
            elem: '#date'
        });

        $('#mobile').on('blur',function(){
            var mobile = $(this).val();
            $('#sendBtn').attr('data-mobile', mobile);
        });

        //监听提交
        form.on('submit(editmobile)', function(data){
            $.ajax({
            url:"<{:U('Account/editMobileShow')}>",
            type:"post",
            data:$('#editmobile').serialize(),
            success:function(res){
                if(res['status'] && res['data'] == 'editNewMobile'){
                    layer.alert("编辑成功", {icon: 6},function () {
                        parent.location.reload();
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                    }); 
                }else if(res['status'] ){
                    layer.alert("编辑成功", {icon: 6},function () {
                        window.location.href = "<{:U('Account/editMobileShow',['editnewmobile'=>1])}>";
                    });
                }else{
                    layer.alert(res.msg ? res.msg :"操作失败", {icon: 5},function () {
                        parent.location.reload();
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                    });
                }
            }
        });
            return false;
        });
    });
</script>
</body>
</html>